﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

    <title>订单管理</title>

    <link href="../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet"
          type="text/css">
    <link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet"
          type="text/css">

    <link href="../css/personal.css" rel="stylesheet" type="text/css">
    <link href="../css/orstyle.css" rel="stylesheet" type="text/css">

    <script src="../AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
    <script src="../AmazeUI-2.4.2/assets/js/amazeui.js"></script>

</head>

<body>
<!--头 -->
<header>
    <article>
        <div class="mt-logo">
            <!--顶部导航条 -->
            <div class="am-container header">
                <ul class="message-l">
                    <div class="topMessage">
                        <div class="menu-hd">
                            <a href="#" target="_top" class="h">亲，请登录</a> <a href="#"
                                                                             target="_top">免费注册</a>
                        </div>
                    </div>
                </ul>
                <ul class="message-r">
                    <div class="topMessage home">
                        <div class="menu-hd">
                            <a href="#" target="_top" class="h">商城首页</a>
                        </div>
                    </div>
                    <div class="topMessage my-shangcheng">
                        <div class="menu-hd MyShangcheng">
                            <a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
                        </div>
                    </div>
                    <div class="topMessage mini-cart">
                        <div class="menu-hd">
                            <a id="mc-menu-hd" href="#" target="_top"><i
                                    class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong
                                    id="J_MiniCartNum" class="h">0</strong></a>
                        </div>
                    </div>
                    <div class="topMessage favorite">
                        <div class="menu-hd">
                            <a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
                        </div>
                </ul>
            </div>

            <!--悬浮搜索框-->

            <div class="nav white">
                <div class="logoBig">
                    <li><img src="../images/logobig.png"/></li>
                </div>

                <div class="search-bar pr">
                    <a name="index_none_header_sysc" href="#"></a>
                    <form>
                        <input id="searchInput" name="index_none_header_sysc" type="text"
                               placeholder="搜索" autocomplete="off"> <input
                            id="ai-topsearch" class="submit am-btn" value="搜索" index="1"
                            type="submit">
                    </form>
                </div>
            </div>

            <div class="clear"></div>
        </div>
        </div>
    </article>
</header>
<div class="nav-table">
    <div class="long-title">
        <span class="all-goods">全部分类</span>
    </div>
    <div class="nav-cont">
        <ul>
            <li class="index"><a href="#">首页</a></li>
            <li class="qc"><a href="#">闪购</a></li>
            <li class="qc"><a href="#">限时抢</a></li>
            <li class="qc"><a href="#">团购</a></li>
            <li class="qc last"><a href="#">大包装</a></li>
        </ul>
        <div class="nav-extra">
            <i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利 <i
                class="am-icon-angle-right" style="padding-left: 10px;"></i>
        </div>
    </div>
</div>
<b class="line"></b>
<div class="center">
    <div class="col-main">
        <div class="main-wrap">

            <div class="user-order">

                <!--标题 -->
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf">
                        <strong class="am-text-danger am-text-lg">订单管理</strong> / <small>Order</small>
                    </div>
                </div>
                <hr/>

                <div class="am-tabs am-tabs-d2 am-margin" data-am-tabs>

                    <ul class="am-avg-sm-5 am-tabs-nav am-nav am-nav-tabs">
                        <li class="am-active titel-li" onclick="changeOrder(10,'tab1',this)"><a href="#tab1" >所有订单</a></li>
                        <li class="titel-li" onclick="changeOrder(0,'tab2',this)"><a href="#tab2"  >待付款</a></li>
                        <li class="titel-li" onclick="changeOrder(1,'tab3',this)"><a href="#tab3" >待发货</a></li>
                        <li class="titel-li"  onclick="changeOrder(2,'tab4',this)"><a href="#tab4" >待收货</a></li>
<!--                        <li><a href="#tab5" onclick="changeOrder(3,'tab5')">待评价</a></li>-->
                    </ul>

                    <div class="am-tabs-bd">
                        <div class="am-tab-panel am-fade am-in am-active" id="tab2">
                            <div class="order-top">
                                <div class="th th-item">
                                    <td class="td-inner">商品</td>
                                </div>
                                <div class="th th-price">
                                    <td class="td-inner">单价</td>
                                </div>
                                <div class="th th-number">
                                    <td class="td-inner">数量</td>
                                </div>
                                <div class="th th-operation">
                                    <td class="td-inner">商品操作</td>
                                </div>
                                <div class="th th-amount">
                                    <td class="td-inner">合计</td>
                                </div>
                                <div class="th th-status">
                                    <td class="td-inner">交易状态</td>
                                </div>
                                <div class="th th-change">
                                    <td class="td-inner">交易操作</td>
                                </div>
                            </div>
                            <div class="order-main">
                                <div class="order-list">

                                </div>

                            </div>

                        </div>
                    </div>

                </div>
            </div>
        </div>
        <!--底部-->
        <div class="footer">
            <div class="footer-hd">
                <p>
                    <b>|</b> <a href="#">商城首页</a> <b>|</b> <a
                        href="#">支付宝</a> <b>|</b> <a href="#">物流</a>
                </p>
            </div>
            <div class="footer-bd">
                <p style="text-align: center;">
                    <a href="#">合作伙伴</a> <a href="#">联系我们</a> <a href="#">网站地图</a> <em
                        style="text-align: center;">© 2015-2025 zking 版权所有</em>
                </p>
            </div>

        </div>
    </div>
    <aside class="menu">
        <ul>
            <li class="person active"><a href="index.html"><i
                    class="am-icon-user"></i>个人中心</a></li>
            <li class="person">
                <p>
                    <i class="am-icon-newspaper-o"></i>个人资料
                </p>
                <ul>
                    <li><a href="information.html">个人信息</a></li>
                    <li><a href="safety.html">安全设置</a></li>
                    <li><a href="address.html">地址管理</a></li>
                    <li><a href="cardlist.html">快捷支付</a></li>
                </ul>
            </li>
            <li class="person">
                <p>
                    <i class="am-icon-balance-scale"></i>我的交易
                </p>
                <ul>
                    <li><a href="order.html">订单管理</a></li>
                    <li><a href="change.html">退款售后</a></li>
                    <li><a href="comment.html">评价商品</a></li>
                </ul>
            </li>
            <li class="person">
                <p>
                    <i class="am-icon-dollar"></i>我的资产
                </p>
                <ul>
                    <li><a href="points.html">我的积分</a></li>
                    <li><a href="coupon.html">优惠券 </a></li>
                    <li><a href="bonus.html">红包</a></li>
                    <li><a href="walletlist.html">账户余额</a></li>
                    <li><a href="bill.html">账单明细</a></li>
                </ul>
            </li>

            <li class="person">
                <p>
                    <i class="am-icon-tags"></i>我的收藏
                </p>
                <ul>
                    <li><a href="collection.html">收藏</a></li>
                    <li><a href="foot.html">足迹</a></li>
                </ul>
            </li>

            <li class="person">
                <p>
                    <i class="am-icon-qq"></i>在线客服
                </p>
                <ul>
                    <li><a href="consultation.html">商品咨询</a></li>
                    <li><a href="suggest.html">意见反馈</a></li>

                    <li><a href="news.html">我的消息</a></li>
                </ul>
            </li>
        </ul>

    </aside>
</div>
//判断用户是否登录
<script type="text/javascript">
    //判断用户是否已经登录
    function isLogin() {
        $.ajax({
            url: "http://localhost:8080/SnacksShop/user.do?type=isLogin",
            type: "post",
            crossDomain: true,
            xhrFields: {
                withCredentials: true
            },
            success: function (data) {
                if (data == "101") {
                    location.href = "./login.html";
                    return;
                }
                data = JSON.parse(data); //解析为Json格式
                $("#user-login-label").hide(); //隐藏登录标签
                $("#userWellcome").html("欢迎登录&nbsp;&nbsp;<span style='color: #ff0000'>" + data.requestAPI.object.userName + "</span>");
                $("#unlogin-box-guanggao").hide();//隐藏
                $("#userImg-cebian").attr("src", data.requestAPI.object.userImg);//显示侧边用户头像
                $("#userName-cebian").text("用户名:" + data.requestAPI.object.userName);//显示侧边用户名
            },
            error: function () {

            }
        })
    }

    isLogin();
</script>
//获取订单
<script type="text/javascript">

    var temp;

    function getUserOrder() {
        $.ajax({
            url: "http://localhost:8080/SnacksShop/user.do?type=getUserAllOrder",
            type: "post",
            crossDomain: true,
            xhrFields: {
                withCredentials: true
            },
            success: function (data) {
                console.log(data);
                data = JSON.parse(data);
                temp = data.data;
                printOrder(data.data, -1);
            },
            error: function () {

            }
        })
    }


    getUserOrder();


    //装换时间
    function getLocalTime(nS) {

        return new Date(parseInt(nS)).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");

    }

    // document.write(getLocalTime(1551417769));
    //获取 JSON 数组长度：
    function getJsonLength(json) {
        var jsonLength = 0;
        for (var i in json) {
            jsonLength++;
        }
        return jsonLength;
    }

    //切换订单
    function changeOrder(status,label_name,self_li){
        $(".titel-li").removeClass("am-active");
        $(self_li).addClass("am-active");
        $(".am-tab-panel .am-fade .am-in .am-active").attr("id",label_name);
        printOrder(temp,status);

    }
    //打印订单
    function printOrder(data, status) {
        var data_length = getJsonLength(data);
        var html = '';
        for (var i = 0; i < data_length; i++) {
            //未付款
            if (status == 0) {
                if (data[i][0].order.orderStatus != 0) {
                    continue;
                }
            }
            //待发货
            if (status == 1) {
                if (data[i][0].order.orderStatus != 1) {
                    continue;
                }
            }
            //待发货
            if (status == 2) {
                if (data[i][0].order.orderStatus != 2) {
                    continue;
                }
            }

            var orderGoods_length = getJsonLength(data[i]);

            html += '<div class="order-status5"><div class="order-title"><div class="dd-num">订单编号：<a href="javascript:;">' + data[i][0].order.orderId + '</a></div> <span>成交时间：' + getLocalTime(data[i][0].order.orderTime.time) + '</span>';
            html += ' </div><div class="order-content"><div class="order-left">';
            for (var j = 0; j < orderGoods_length; j++) {
                html += '<ul class="item-list"><li class="td td-item"><div class="item-pic">';
                html += '<a href="#" class="J_MakePoint"><img src="' + data[i][j].taste.tasteImg + '" class="itempic J_ItemImg"></a></div><div class="item-info"><div class="item-basic-info">';
                html += ' <a href="#"><p>' + data[i][j].taste.goods.goodsName + '</p><p class="info-little">口味：' + data[i][j].taste.tasteName + ' <br/></p></a></div>';
                html += '</div></li><li class="td td-price"><div class="item-price">' + data[i][j].orderPrice.toFixed(2) + '</div></li><li class="td td-number">';
                html += '<div class="item-number"><span>×</span>' + data[i][j].orderGoodsNumber + '</div></li><li class="td td-operation"><div class="item-operation"></div></li></ul>';
            }
            html += '</div><div class="order-right"><li class="td td-amount"><div class="item-amount">合计：' + data[i][0].order.orderPrice + '<p><span></span></p>';
            html += '</div></li><div class="move-right"> <li class="td td-status"><div class="item-status">';
            //未支付状态
            if (data[i][0].order.orderStatus == 0) {
                html += '<p class="Mystatus">未付款</p>';
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">立即付款</div></li></div></div></div></div>';
            }
            //已支付状态，待发货
            if (data[i][0].order.orderStatus == 1) {
                html += '<p class="Mystatus">已付款</p>';
                html += ' <p class="order-info">' +
                    ' <a >等待发货</a>' +
                    '</p>'
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">发起退款</div></li></div></div></div></div>';
            }
            //已支付状态，已发货待确收
            if (data[i][0].order.orderStatus == 2) {
                html += '<p class="Mystatus">已付款</p>';
                html += ' <p class="order-info">' +
                    ' <a >已发货</a>' +
                    '</p>'
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">确认收货</div></li></div></div></div></div>';
            }
            //正在退单
            if (data[i][0].order.orderStatus == 3) {
                html += '<p class="Mystatus">已付款</p>';
                html += ' <p class="order-info">' +
                    ' <a >等待退款</a>' +
                    '</p>'
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">退款处理</div></li></div></div></div></div>';
            }

            //退单成功
            if (data[i][0].order.orderStatus == 4) {
                html += '<p class="Mystatus">已付款</p>';
                html += ' <p class="order-info">' +
                    ' <a >退款成功</a>' +
                    '</p>'
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">退款成功</div></li></div></div></div></div>';
            }
            //交易成功
            if (data[i][0].order.orderStatus == 5) {
                html += '<p class="Mystatus">已付款</p>';
                html += ' <p class="order-info">' +
                    ' <a >交易成功</a>' +
                    '</p>'
                html += '</div></li><li class="td td-change"><div class="am-btn am-btn-danger anniu">交易成功</div></li></div></div></div></div>';
            }

        }

        $(".order-list").html(html);
    }
</script>
</body>

</html>